Skip to content

DOCS: Add examples to Triangle methods and properties (#704)#719

Merged
kennethshsu merged 1 commit intocasact:mainfrom
EKtheSage:docs/issue-704-triangle-methods-examples
Apr 29, 2026
Merged

DOCS: Add examples to Triangle methods and properties (#704)#719
kennethshsu merged 1 commit intocasact:mainfrom
EKtheSage:docs/issue-704-triangle-methods-examples

Conversation

@EKtheSage
Copy link
Copy Markdown
Contributor

@EKtheSage EKtheSage commented Apr 25, 2026

What does this pull request do?

Addresses #704 for the Triangle class methods and properties (the second tranche after #714, which covered the constructor).

Adds doctest-validated Examples blocks to 19 Triangle methods and properties, using the same Polars-style format established in #714: no import statements, ... continuation prefixes, and strict output indentation at the same base level as >>>.

Methods (Examples added to existing docstrings)

  • incr_to_cum, cum_to_incr
  • dev_to_val, val_to_dev
  • grain
  • trend
  • shift, sort_axis
  • development_correlation, valuation_correlation

Properties (Examples added to existing docstrings)

  • link_ratio, is_full

Properties (full docstrings written from scratch)

These had no docstring or only a one-line description before this PR:

  • age_to_age (alias of link_ratio)
  • is_ultimate, is_pattern, is_val_tri
  • latest_diagonal
  • origin, development

Data choices

  • cl.load_sample('ukmotor') is used as the default 7x7 cumulative example data. Its width fits cleanly inside a docstring and matches the convention used elsewhere in the package.
  • cl.load_sample('raa') is used for development_correlation / valuation_correlation since it is the canonical Mack 1997 dataset.
  • Hand-crafted DataFrames are used where a sample does not provide the right shape (incremental data for incr_to_cum, OQDQ for grain, small numeric examples for trend / shift).
  • Boolean property examples use bool(...) to extract the underlying value, since the properties return numpy booleans whose repr is np.True_ / np.False_.

Validation

All 19 example blocks were executed with Python's doctest module in strict mode (no NORMALIZE_WHITESPACE flag) and pass with byte-exact output comparison.

Other

Adds .scratch/ to .gitignore for local handoff notes and throwaway verification scripts.

Relevent Github ticket(s)?

Issue #704. Companion to PR #714 (constructor examples).


Note

Low Risk
Changes are docstring-only (plus .gitignore) and do not modify runtime logic, so functional risk is minimal; main risk is doc build/doctest formatting issues.

Overview
Expands Triangle API documentation by adding/new-writing detailed docstrings with doctest-style Examples for key properties (origin, development, is_val_tri, is_pattern, is_ultimate, latest_diagonal, age_to_age) and for methods including incr_to_cum, cum_to_incr, dev_to_val, val_to_dev, grain, trend, shift, sort_axis, development_correlation, and valuation_correlation.

Also updates .gitignore to include a local .scratch/ directory (and normalizes the .idea ignore entry).

Reviewed by Cursor Bugbot for commit 4a07452. Bugbot is set up for automated code reviews on this repo. Configure here.

Adds doctest-validated Examples blocks to 19 Triangle methods and
properties, matching the Polars-style format used in the constructor
PR: no imports, "..." continuation lines, and strict output indentation.

Methods with Examples added to existing docstrings:
incr_to_cum, cum_to_incr, dev_to_val, val_to_dev, grain, trend, shift,
sort_axis, development_correlation, valuation_correlation.

Properties with Examples added to existing docstrings:
link_ratio, is_full.

Properties with full docstrings written from scratch:
age_to_age, is_ultimate, is_pattern, is_val_tri, latest_diagonal,
origin, development.

All 19 example blocks validated with strict doctest (no
NORMALIZE_WHITESPACE flag).

Also adds .scratch/ to .gitignore for local handoff notes and
throwaway verification scripts.
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 25, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 85.12%. Comparing base (6ea3577) to head (4a07452).
⚠️ Report is 6 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #719   +/-   ##
=======================================
  Coverage   85.12%   85.12%           
=======================================
  Files          85       85           
  Lines        4909     4909           
  Branches      629      629           
=======================================
  Hits         4179     4179           
  Misses        521      521           
  Partials      209      209           
Flag Coverage Δ
unittests 85.12% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@kennethshsu kennethshsu merged commit 1d4f596 into casact:main Apr 29, 2026
8 checks passed
kennethshsu pushed a commit that referenced this pull request Apr 29, 2026
Adds doctest-validated Examples blocks to the five deterministic IBNR
estimator classes, matching the Polars-style format used in PRs #714
and #719: no imports, "..." continuation lines, strict output
indentation, and byte-exact output (no NORMALIZE_WHITESPACE).

Per-class coverage:

- Chainladder: class docstring, fit, predict
- MackChainladder: class docstring, fit, predict (predict had no
  docstring before this PR), and five property docstrings written from
  scratch: full_std_err_, total_process_risk_, mack_std_err_,
  total_mack_std_err_, summary_
- BornhuetterFerguson: class docstring, fit, predict. Class docstring
  notes the apriori-as-Triangle requirement (a literal int sample_weight
  raises AttributeError) and explains the canonical
  "cl_ult * 0 + value" broadcasting idiom for building a flat per-origin
  apriori
- Benktander: class docstring, fit, predict. Class docstring shows that
  n_iters interpolates between BF (n_iters=1) and chainladder (n_iters
  large)
- CapeCod: class docstring, fit, predict. Class docstring contrasts
  CapeCod with BF/Benktander (sample_weight is exposure, apriori is
  derived) and demonstrates the trend and decay parameters

All 20 example blocks validated with strict doctest.
kennethshsu pushed a commit that referenced this pull request Apr 29, 2026
Adds doctest-validated Examples block to the TailConstant class docstring covering tail, decay, and projection_period parameters. Follows the polars-style >>> doctest convention established in #714 and #719. All 9 example interactions pass strict doctest with byte-exact output matching.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants